<?php
    $logged_in = (!empty($user_status['is_logged_in'])) ? $user_status['is_logged_in'] : false;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title><?=$page_title?> - Mini-Google Private NetWork</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="<?=base_url()?>css/header.css" rel="stylesheet" type="text/css"/>
    <?=(isset($_css)) ? $_css : '' ?>
    <script type="text/javascript" src="<?=base_url()?>js/jquery.js"></script>
</head>
<body>
<script type="text/javascript">
    function TextBoxHelper(obj) {
        var objDefault = $(obj).val();
        $(obj).select();
        obj.select();
        $(obj).blur(function() {
            if ($(obj).val() == '') {
                $(obj).attr('value', objDefault);
            }
        });
    }
    function show_msg() {
        var obj = $('#header_msgBox');
        var obj_orgHTML = obj.html();
        obj.css('margin-left', -(obj.width() / 2));
        obj.show('normal');
        $('#header_msgBox_content').load('<?=site_url('index/show_msg')?>');
    }

    function close_msg(){
        $('#header_msgBox').hide('normal');
        $('#header_msgBox_content').load('<?=site_url('index/close_msg')?>',{'read':'1'},function()
        {
            $('#msg_counter').html('No');
            $('#msg_counter').css({'color':'black','text-decoration':'none'});
        });

    }
    $(document).ready(function() {
        $("#header_items_login").click(function() {
            var top = $(this).innerHeight();
            $("#header_loginBox").css({'top':top - 1,'right':0});
            $("#header_loginBox").toggle('normal');
            $("#header_loginBox").focus();
        });

        $('#logout').click(function() {
            $(this).load('<?=site_url('login/logout')?>', function() {
                setTimeout(function() {
                    $('#logout').html('Good Bye')
                }, 500);
                setTimeout(function() {
                    window.location = "<?=site_url()?>"
                }, 1000);
            });

        });
        var pick = '#header_items_<?=$_marker ?>';
        var marker = $('#header_items_mark');
        var offset = $(pick).offset();
        marker.css('left', offset.left);
        marker.css('width', $(pick).innerWidth());
    });
</script>
<div id="header_selectorBar">
    <div id="header_items_mark">
        <div style="background-color:blue; width:98%; margin:auto;height:3px;">&nbsp;</div>
    </div>
</div>
<div id="header_container">
    <a href="<?=base_url()?>">
        <div class="header_items" id="header_items_web">
            Web
        </div>
    </a>
    <a href="<?=site_url('index/image')?>">
        <div class="header_items" id="header_items_image">
            Images
        </div>
    </a>
    <a href="<?=site_url('index/stats')?>">
        <div class="header_items" id="header_items_stats">
            Statistics
        </div>
    </a>

    <div class="header_items" id="header_items_login">
<?php
        if ($logged_in) {
    echo 'Logout/Control Panel';
}
else
{
    echo 'Login/Register';
}
    ?>

    </div>

    <div class="" id="header_items_greet">
        Welcome, <?=($logged_in) ? $user_status['username'] . '! You have ' . $num_msg : 'Guest!' ?>
    </div>
</div>

<div id="header_loginBox">
<?php
        if ($logged_in):?>
    <!--    <a href="--><?//=site_url('login/logout')?><!--">-->
    <div id="logout">Logout</div>
    <!--    </a>-->
    <a href="<?=site_url('user_cp')?>">
        <div id="user_cp">Control Panel</div>
    </a>
    <?
else:
    ?>
    <p>Login or Sign up</p>
    <? echo form_open('login/validate'); ?>
    <input onclick="TextBoxHelper(this)" name="username" value="Username" type="text"/>
    <input onclick="TextBoxHelper(this)" name="password" value="Password" type="password"/>
    <div id="login_error"></div>
    <input type="submit" id="login_submit" value="Login" style="float:left;"/>
    <input type="reset" id="login_reset" value="Reset" style="float:left; margin-left:10px"/>
    <p style="float:right;"><a href="<?=site_url('login/reg')?>" target="_self">Register</a></p>
    <? echo form_close(); ?>
    <?
endif;
    ?>
</div>
<div id="header_msgBox">
    <div id="header_msgBox_content"></div>
    <div id="header_msgBox_close" onclick="close_msg()">Close</div>
</div>